package com.ruoyi.teacher.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.TProject;
import com.ruoyi.teacher.service.ITProjectService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 结题/验收项目信息集Controller
 *
 * @author xiangzy
 * @date 2022-05-10
 */
@Api(tags = "结题管理")
@RestController
@RequestMapping("/teacher/project")
public class TProjectController extends BaseController
{
    @Autowired
    private ITProjectService tProjectService;

    /**
     * 查询结题/验收项目信息集列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProject tProject)
    {
        startPage();
        List<TProject> list = tProjectService.selectTProjectList(tProject);
        return getDataTable(list);
    }

    /**
     * 导出结题/验收项目信息集列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:project:export')")
    @Log(title = "结题/验收项目信息集", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProject tProject)
    {
        List<TProject> list = tProjectService.selectTProjectList(tProject);
        ExcelUtil<TProject> util = new ExcelUtil<TProject>(TProject.class);
        return util.exportExcel(list, "project");
    }

    /**
     * 获取结题/验收项目信息集详细信息
     */
    @ApiOperation(value = "获取结题/验收项目信息集详细信息")
    @PreAuthorize("@ss.hasPermi('teacher:project:query')")
    @GetMapping(value = "/{recordid}")
    public AjaxResult getInfo(@PathVariable("recordid") Long recordid)
    {
        return AjaxResult.success(tProjectService.selectTProjectById(recordid));
    }

    /**
     * 新增结题/验收项目信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:project:add')")
    @Log(title = "结题/验收项目信息集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProject tProject)
    {
        return toAjax(tProjectService.insertTProject(tProject));
    }

    /**
     * 修改结题/验收项目信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:project:edit')")
    @Log(title = "结题/验收项目信息集", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProject tProject)
    {
        return toAjax(tProjectService.updateTProject(tProject));
    }

    /**
     * 删除结题/验收项目信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:project:remove')")
    @Log(title = "结题/验收项目信息集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordids}")
    public AjaxResult remove(@PathVariable Long[] recordids)
    {
        return toAjax(tProjectService.deleteTProjectByIds(recordids));
    }
}
